/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;

/**
 *
 * @author cesardoncel
 */
@ManagedBean(name = "utilController")
@SessionScoped
public class Utilidades {       
   
    
    public Collection<SelectItem> getEstadoUsuario() {
	List<SelectItem> estadoUsuario = new ArrayList<SelectItem>();
        try {
            estadoUsuario.add(new SelectItem("ACTIVO", "ACTIVO"));
            estadoUsuario.add(new SelectItem("INACTIVO", "INACTIVO"));
        } catch (Exception e) {
            e.getCause();
        }
	return estadoUsuario;
    }
    
    public Collection<SelectItem> getPonderacion(long p) {
	List<SelectItem> ponderacion = new ArrayList<SelectItem>();
        try {
            int sum = (int) p;
            int dif = 100 - sum;
            for (int x = 1; x<=dif; x++){
                ponderacion.add(new SelectItem(x, ""+x));
            }
        } catch (Exception e) {
            e.getCause();
        }
	return ponderacion;
    }    
    
    public void generarDocumento() {
        FacesContext context = FacesContext.getCurrentInstance();
        String baseURL = context.getExternalContext().getRequestContextPath();
        String url = baseURL + "/DocumentoFinal";

        try {            
            context.getExternalContext().redirect(url);
        } catch (Exception e) {
            e.printStackTrace();
            // Handle the exception here ...
        } finally {
            context.responseComplete();
        }
    }
}
